import React from 'react'
import { LeftOutlined,PlusOutlined } from '@ant-design/icons';
import { Button, Radio, Form, Input, Upload } from 'antd';
import { putUserDjm } from '../../api/api';
import { useNavigate, useParams } from 'react-router-dom';
export default function Renzheng() {
  const navigate = useNavigate()
  const {id} = useParams()
  const onFinish = (values) => {
    console.log('Success:', values);
    if(values.username&&values.xingbie&&values.school&&values.schoolnumber){
      putUserDjm({id,ren:true}).then(res=>{console.log(res)})
      navigate('/zhongxin')
    }else{
      alert('请输入完整')
    }
  };
  const normFile = (e) => {
    if (Array.isArray(e)) {
      return e;
    }
    return e?.fileList;
  };
  return (
    <div>
      <Form
        name="basic"
        labelCol={{
          span: 8,
        }}
        wrapperCol={{
          span: 16,
        }}
        style={{
          maxWidth: 600,
        }}
        initialValues={{
          remember: true,
        }}
        onFinish={onFinish}
        autoComplete="off"
      >
       <header style={{display:'flex',alignItems: 'center',justifyContent: 'space-between',padding:'0 10px',height:'50px'}}>
          <LeftOutlined onClick={()=>{
            window.history.back()
          }}/>
          <h4>实名认证</h4>
          <div> 
            <Button type="primary" htmlType="submit">
                提交
            </Button>
          </div>
        </header> 

            <Form.Item
              label="名字"
              name="username"
            >
              <Input />
            </Form.Item>

            <Form.Item
              label="性别"
              name="xingbie"
            >
              <Radio.Group>
                <Radio value="男"> 男 </Radio>
                <Radio value="女"> 女 </Radio>
              </Radio.Group>
            </Form.Item>
            <Form.Item
              label="学校"
              name="school"
            >
              <Input />
            </Form.Item>
            <Form.Item
              label="学号"
              name="schoolnumber"
            >
              <Input />
            </Form.Item>

            <Form.Item label="学生证" valuePropName="fileList" getValueFromEvent={normFile} name="img">
              <Upload action="" listType="picture-card">
                <div>
                  <PlusOutlined />
                </div>
              </Upload>
            </Form.Item>
          </Form>

    </div>
  )
}
